package com.dwms.controller;

import com.dwms.entity.PageResponse;
import com.dwms.entity.QueryRequest;
import com.dwms.entity.Result;
import com.dwms.entity.base.sellerCeb.request.SellerCebQueryRequest;
import com.dwms.entity.base.sellerCeb.request.SellerCebRequest;
import com.dwms.entity.base.sellerCeb.response.SellerCebResponse;
import com.dwms.feign.seller.SellerCebFeignClient;
import com.dwms.utils.WebUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: SellerCebController
 * @Description: SellerCeb
 * @Create 2025-08-27 14:41:10
 * @Author WH
 * @Since 1.0.0
**/
@Tag(name = "商家备案管理")
@RestController
@RequestMapping(value = "/seller/ceb")
@RequiredArgsConstructor
public class SellerCebController {

    private final HttpServletRequest request;
    private final SellerCebFeignClient sellerCebFeignClient;

    /**
     * 保存
     *
     * @param sellerCebRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "新增商家备案")
    @PostMapping("/save")
    public Result save(@RequestBody SellerCebRequest sellerCebRequest) {
        WebUtil.getAdminRequest(request, sellerCebRequest);
        return sellerCebFeignClient.save(sellerCebRequest);
    }

    /**
     * 修改
     *
     * @param sellerCebRequest
     *          请求参数
     * @return
     */
    @Operation(summary = "修改商家备案")
    @PostMapping("/update")
    public Result update(@RequestBody SellerCebRequest sellerCebRequest) {
        WebUtil.getAdminRequest(request, sellerCebRequest);
        return sellerCebFeignClient.update(sellerCebRequest);
    }
    

    /**
     * 分页查询
     *
     * @param query
     *          查询参数
     * @return
     */
    @Operation(summary = "分页查询")
    @PostMapping("/findPage")
    public Result<PageResponse<SellerCebResponse>> findPage(@RequestBody SellerCebQueryRequest query) {
        WebUtil.getAdminRequest(request, query);
        return sellerCebFeignClient.findPage(query);

    }

    /**
     *  根据ID查询
     *
     * @param query
     *          参数
     * @return
     */
    @Operation(summary = "根据ID查询")
    @PostMapping("/findById")
    public Result findById(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request, query);
        return this.sellerCebFeignClient.findById(query);
    }

    /**
     * 删除
     *
     * @param query
     *          ID
     * @return
     */
    @Operation(summary = "删除备案")
    @PostMapping("/delete")
    public Result delete(@RequestBody QueryRequest query){
        WebUtil.getAdminRequest(request, query);
        return this.sellerCebFeignClient.delete(query);
    }

}
